from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.


class User(AbstractUser):
    phone = models.IntegerField('phone', blank=True, null=True)


class Train(models.Model):
    def __str__(self):
        return str(self.ID)
    ID = models.CharField('id', max_length=100, primary_key=True)
    Name = models.CharField('name', max_length=100)
    Type = models.CharField('type', max_length=10)
    State = models.CharField('state', max_length=30)
    From = models.CharField('from', max_length=30)
    To = models.CharField('to', max_length=30)


class Book(models.Model):
    def __str__(self):
        return str(self.TicketNumber)
    TicketNumber = models.CharField('ticket_number', max_length=100, primary_key=True)
    User = models.ForeignKey(User, on_delete=models.CASCADE)
    Train = models.ForeignKey(Train, on_delete=models.CASCADE)
    Seat = models.CharField('seat', max_length=100)
